***Figures 
**Changing directory to figures

***Log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Appendix Figures"
clear all
log using Log_A3.log, replace

clear
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use CEM_data

cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures"

tab US_firm
sum cem_weights
**We need to convert weights to integers for the figure. 
*To avoid losing information due to rounding, we multiply the weights by 100 prior to getting integer numbers
gen cem_weightaux=cem_weights*100
gen w_int=trunc(cem_weightaux)


**Unweigthed 
qui twoway (histogram log_assets if US_firm==0, bin(30) fintensity(10) percent bcolor(blue)) (histogram log_assets if US_firm==1, bin(30) percent fcolor(none) lcolor(black) lpattern(shortdash)) , ///
 legend(order(1 "Unweigthed" 2 "US IPOs" )) graphregion(color(white)) bgcolor(white) ytitle(Percent of Observations) title (Unweigthed vs US firms)
qui graph save Unweigthed_vs_US, replace  

**Weigthed
qui twoway (histogram log_assets if US_firm==0 [fweight = w_int], bin(30) fintensity(10) percent bcolor(orange)) (histogram log_assets if US_firm==1, bin(30) percent fcolor(none) lcolor(black) lpattern(shortdash)) , ///
 legend(order(1 "CEM weigthed" 2 "US IPOs" )) graphregion(color(white)) bgcolor(white) ytitle(Percent of Observations) title (CEM Weigthed vs US firms)
qui graph save Weigthed_vs_US, replace
   
graph combine Unweigthed_vs_US.gph Weigthed_vs_US.gph,   col(2)   
graph export "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures\vs US.tif", as(tif) replace

graph export A3.pdf, replace



**Closing log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Appendix Figures"
log close
graphlog using Log_A3.log, lspacing(1) replace
****************************
